#pragma once
#include "GameObject.h"
#include "Playfield.h"
#include "Player.h"
#include "GameMode.h"
#include "VisualObjectProvider.h"
#include "Sparks.h"

class Ball :
	public GameObject
{
public:
	Ball(VisualObjectProvider* vObjProv, Playfield &playfield, Player &left, Player &right, GameMode &gamemode);
	~Ball(void);

	virtual void update(const double time);
	virtual void getReadyForDraw();
	virtual void draw();

	virtual const int getWidth() { return width; }
	virtual const int getHeight() { return height; }

	bool hasScored();
	void reset();
	PlayerPosition whoScored();

private:

	bool intersectsWithPlayer(Player &pl);
	void increaseSpeed();
	void showSparks(PlayerPosition pos);

	Playfield &playfield;
	Player &leftPlayer, &rightPlayer;
	const int width, height;

	void updateIntro(const double time);
	void updatePlay(const double time);
	double realX, realY;
	double vx, vy;
	Sparks *spark;

	GameMode &gamemode;
	VisualObjectProvider *visualObjectProvider;
};
